package com.zh.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import com.zh.pojo.dto.WechatLoginDto;
import com.zh.pojo.result.LoginSuccess;
import com.zh.result.JSONResult;
import com.zh.service.ILoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 微信小程序认证中心
 */
@Tag(name = "登录对象",description = "登录对象")
@RestController
@RequestMapping("/app/login")
public class AppLoginController {

    @Autowired
    public ILoginService loginService;

    /**
     *  微信小程序登录接口
     * @param loginDto
     * @return
     */
    @Operation( summary= "微信小程序登录接口",description = "微信小程序登录接口")
    @Parameter(name = "login",description = "登录的对象",required = true)
    @PostMapping("/wechat")
    // 此接口加上了 @SaIgnore 可以游客访问
    @SaIgnore
    public JSONResult wechatLogin(@RequestBody @Valid WechatLoginDto loginDto){
        LoginSuccess loginSuccess = loginService.wechatLogin(loginDto);
        return JSONResult.success(loginSuccess);
    }



}
